home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 5
/
Aminet 5 - March 1995.iso
/
Aminet
/
game
/
2play
/
LordOfHosts.lha
/
LordOfHosts
/
lohsrc.lzh
/
joymouse.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-05-10
|
2KB
|
62 lines
/* LORD OF HOSTS - joymouse.c --- Maus-Joystick-Umschalter */
#include "Lord.h"
extern struct IOStdReq *IOReq;
extern ULONG JoyMouseData;
BOOL joymouse_on;
struct Interrupt Input_Handler;
#pragma regcall(JoyMouseHandler(a0,a1)) /* dann brauche ich keinen Assembler-
Stub für die Parameter */
struct InputEvent *JoyMouseHandler (struct InputEvent *Event, ULONG *Data)
/* Dies ist das Stück Interrupt-Code, das sich jede Mausbewegung schnappt,
bevor Intuition selbst drankommt, sie "streckt" (und alle anderen Events
durchläßt) */
{
if (Event->ie_Class == IECLASS_RAWMOUSE)
{
Event->ie_X *= *Data;
Event->ie_Y *= *Data;
}
return Event;
}
void swapjoymouse(BOOL what)
/* swapjoymouse(TRUE) schaltet Joymouse an, FALSE dagegen aus */
{
UBYTE Type,Port;
if (what == TRUE)
{
Type = GPCT_RELJOYSTICK; /* Joystick als Eingabegerät */
Port = 1; /* am Gameport 2 */
Input_Handler.is_Code = (VOID (*)())JoyMouseHandler;
Input_Handler.is_Data = (APTR) &JoyMouseData;
Input_Handler.is_Node.ln_Pri = 51;
IOReq->io_Data = (APTR) &Input_Handler;
IOReq->io_Command = (UWORD) IND_ADDHANDLER;
DoIO((struct IORequest *)IOReq); /* Handler einbinden */
}
else
{
Type = GPCT_MOUSE; /* Maus als Eingabegerät */
Port = 0; /* am Gameport 1 */
IOReq->io_Data = (APTR) &Input_Handler;
IOReq->io_Command = (UWORD) IND_REMHANDLER;
DoIO((struct IORequest *)IOReq); /* Handler entfernen */
}
/* Port wechseln */
IOReq->io_Data = (APTR) &Port;
IOReq->io_Length = 1;
IOReq->io_Command = (UWORD) IND_SETMPORT;
DoIO((struct IORequest *)IOReq);
/* Controllertyp umschalten */
IOReq->io_Data = (APTR) &Type;
IOReq->io_Length = 1;
IOReq->io_Command = (UWORD) IND_SETMTYPE;
DoIO((struct IORequest *)IOReq);
joymouse_on = what;
}